/*
 * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
 *
 * Licensed under the Aduna BSD-style license.
 */

package edu.tju.commons.collections;

import java.util.Comparator;

/**
 * ReverseComparator reverses the result of another Comparator.
 */
public class ReverseComparator<T> implements Comparator<T> {

	private Comparator<T> other;

	/**
	 * Construct a new reverse comparator that reverses the result of the
	 * specified comparator.
	 * 
	 * @param other
	 *            the comparator to reverse
	 */
	public ReverseComparator(Comparator<T> other) {
		this.other = other;
	}

	public int compare(T o1, T o2) {
		return other.compare(o2, o1);
	}
}
